/**********************************************************************/
/*****                                                            *****/
/*****  TITLE:          BJPS Gender Paper (Djupe, McClurg, Sokhey)*****/                        
/*****  UPDATE:         December 2015                             *****/
/*****  DESC:           Code variables from American component    *****/
/*****                  of the 1992 Cross-National Election Study *****/
/*****                  to replicate (part of) Table 1 of Mutz's  *****/
/*****                  (2002) AJPS &                             *****/
/*****                  Estimate models accounting for gender     *****/                        
/**********************************************************************/

*Additional Notes/Extended Description: 

*The American Component of the 1992 CNEP is available at ICPSR at: http://www.icpsr.umich.edu/icpsrweb/DSDR/studies/6541
*The original file is archived in SPSS format.
*After running the SPSS set-up, we created a stata version of the data set (1992cnes.dta) -- this do-file starts with that initial, non-recoded/non-transformed stata file. 
*Load the accompanying "1992cnes.dta," and then run this do-file to obtain the estimates and figures in the main body of the paper 

/*************************************
*syntax begins here:                  */ 
****************************************

/****** recoding of variables and labeling ****/

*******************************************************
**dependent variables appearing in Table 1 of article**
*******************************************************

rename v43 voted
label var voted "voted in 1992 election"
recode voted 1=1 3=0 5=0 7=0 8=. 9=. 
label def voted 1 "Voted" 0 "did not vote" 
label values voted voted

rename v50 voted88
label var voted88 "voted in 1988" 
recode voted88 1=1 2=1 3=0 4=0 5=. 8=. 9=. 
label def voted88 1 "voted in 88" 0 "didn't vote" 
label values voted88 voted88 

*generate the vote variable Mutz uses in Table 1
*note: this is vote choice in 1988 and 1992, despite temporal ordering

generate vote8892=voted+voted88 

rename v44 votechoice
label var votechoice "vote choice in 1992"
recode votechoice 0=. 1=1 3=2 5=3 7=4 8=. 9=. 
label def votechoice 1 "Bush" 2 "Clinton" 3 "Perot" 4 "Other" 
label values votechoice votechoice

/*create dummies for vote choice in case they're helpful for later analysis*/
recode votechoice 1=1 2=0 3=0 4=0, gen(Bushvote)
recode votechoice 2=1 1=0 3=0 4=0, gen(Clinvote)
recode votechoice 3=1 1=0 2=0 4=0, gen(Perotvote)

/*create a three way votechoice*/

recode votechoice 1=1 2=2 3=3 4=., gen(votechoice2)
label def votechoice2 1 "Bush" 2 "Clinton" 3 "Perot"
label values votechoice2 votechoice2

recode v47 (1=1) (2=1) (3=0) (4=.) (5=.) (8=.) (9=.), gen(congvote)
label def congvote 1 "voted for congress" 0 "did not vote for congress" 
label values congvote congvote

rename v47 congvotechoice
label var congvotechoice "vote choice in Congress"
recode congvotechoice 1=1 2=2 3=. 4=. 5=3 8=. 9=. 
label def congvotechoice 1 "democrat" 2 "republican" 3 "other" 
label values congvotechoice congvotechoice

rename v46 whenvote
label var whenvote "when decided vote choice"
recode whenvote 7=0 5=1 3=2 1=3 8=. 9=. 
label def whenvote 0 "before summer" 1 "summer" 2 "fall" 3 "week before"
label values whenvote whenvote

/*creating participation items*/

/*these are the confrontational items */

rename v132 convince 
label var convince "convinced others" 
recode convince 1=1 5=0 8=. 9=. 
label def convince 1 "yes" 0 "no" 
label values convince convince 

rename v133 workcampaign 
label var workcampaign "worked for a campaign" 
recode workcampaign 1=1 5=0 8=. 9=. 
label def workcampaign 1 "yes" 0 "no" 
label values workcampaign workcampaign

/*this is the confrontational index*/

generate confront=convince+workcampaign 

/*these are the non-confrontational items */

rename v134 rallies 
label var rallies "attended rallies" 
recode rallies 1=1 5=0 8=. 9=. 
label def rallies 1 "yes" 0 "no" 
label values rallies rallies 

rename v135 sign  
label var sign "displayed sign" 
recode sign 1=1 5=0 8=. 9=. 
label def sign 1 "yes" 0 "no" 
label values sign sign 

rename v136 givemoney  
label var givemoney "gave money" 
recode givemoney 1=1 5=0 8=. 9=. 
label def givemoney 1 "yes" 0 "no" 
label values givemoney givemoney

/*this is the non-confrontataionl index */

generate nonconindex=rallies+sign+givemoney 

/*this is the overall participatory index (the two previous added together) */

generate partindex=confront+nonconindex


/*create control variables */

rename v51 interest 
label var interest "political interest"
recode interest 5=0 3=1 1=2 8=. 9=. 
label def interest 0 "not much" 2 "very much"
label values interest interest 

rename v52 pid3
label var pid3 "three-way pid"
recode pid3 1=1 2=2 5=3 3=3 4=3 8=. 9=. 
label def pid3 1 "Democrats" 2 "Republicans" 3 "independents"
label values pid3 pid3

rename v54 str
label var str "branching strength for partisans"
recode str 1=1 2=1 3=2 4=2 5=3 8=. 9=. 
label def str 1 "strong" 2 "weak" 3 "lean"
label values str str

/*create 7-point party id*/
gen pid7=.
replace pid7=1 if pid3==1 & str==1
replace pid7=2 if pid3==1 & str==2
replace pid7=3 if pid3==1 & str==3
replace pid7=3 if pid3==3 & v53==5
replace pid7=4 if pid3==3 & v53==7
replace pid7=5 if pid3==2 & str==3
replace pid7=5 if pid3==3 & v53==1
replace pid7=6 if pid3==2 & str==2
replace pid7=7 if pid3==2 & str==1
label def pid7 1 "strong dem" 2 "weak dem" 3 "lean dem" 4 "ind" 5 "lean GOP" 6 "weak GOP" 7 "strong GOP"
label values pid7 pid7

*create separate republican and democratic strength measures 

recode pid7 (4=1) (3=2) (2=3) (1=4) (else=0), gen(strdem)
recode pid7 (4=1) (5=2) (6=3) (7=4) (else=0), gen(strrep)

rename v260 income25
recode income25 1=1 5=0 8=. 9=. 

rename v261 income15
recode income15 1=1 5=0 8=. 9=. 

rename v262 income35
recode income35 1=1 5=0 8=. 9=. 

rename v263 income50
recode income50 1=1 5=0 8=. 9=. 

rename v264 income75
recode income75 1=1 5=0 8=. 9=. 

gen income=.
replace income=0 if income15==1
replace income=1 if income15==0
replace income=2 if income35==0
replace income=3 if income50==0
replace income=4 if income75==0
replace income=5 if income75==1

rename v87 gender
recode gender 1=0 5=1 8=. 9=. 
label def gender 0 "male" 1 "female" 
label values gender gender

rename v181 ageraw 
recode ageraw 9998=. 9999=. 

gen age=1992-ageraw

rename v182 race
recode race 8=. 9=. 

rename v183 hispanic
recode hispanic 1=1 5=0 8=. 9=. 

gen white=0
replace white=1 if race==1
replace white=1 if race==1 & hispanic==0
label var white "R is non-hispanic white"

rename v173 education 
recode education (0/11=1) (12=2) (13/15=3) (20=3) (16=4) (17/19=5) (98=.) (99=.) 


/*create discussion network measures*/
rename v185 d1
label var d1 "R names first discussant"
recode d1 5=0
label val d1 yesno
label values d1 d1

rename v187 d2
label var d2 "R names second discussant"
recode d2 5=0
label val d2 yesno
label values d2 d2

rename v189 d3
label var d3 "R names third discussant"
recode d3 5=0
label val d3 yesno
label values d3 d3

rename v191 d4
label var d4 "R names fourth discussant"
recode d4 5=0
label val d4 yesno
label values d4 d4

rename v193 d5
label var d5 "R names fifth, political discussant"
recode d5 5=0
label val d5 yesno
label values d5 d5


/*discussant 1*/
rename v201 d1education
recode d1education 1=1 3=2 5=3 8=. 9=. 
label var d1education "level of education of discussant"
label def d1education 1 "less than high school" 2 "high school" 3 "college degree"
label values d1education d1education

rename v202 d1ptalk
label var d1ptalk "freq R talks politics with d1"
recode d1ptalk 4=0 3=1 2=2 1=3 8=. 9=. 
label def d1ptalk 0 "never" 3 "often"
label values d1ptalk d1ptalk

rename v203 d1frqdis
label var d1frqdis "freq R disagrees with d1"
recode d1frqdis 4=0 3=1 2=2 1=3 8=. 9=. 
label def d1frqdis 0 "never" 3 "often" 
label values d1frqdis d1frqdis

rename v204 d1gender 
recode d1gender 1=1 5=0 8=. 9=. 
label def d1gender 1 "male" 
label values d1gender d1gender

rename v205 d1know
label var d1know "how much d1 knows about politics"
recode d1know 5=0 3=1 1=2 8=. 9=. 
label def d1know 0 "not much" 1 "avg amount" 2 "a great deal" 
label values d1know d1know

rename v206 d1vote
label var d1vote "who did d1 vote for in election?"
recode d1vote 5=4 6=4 7=4 0=4 8=. 9=. 
label def d1vote 1 "Bush" 2 "Clinton" 3 "Perot" 4 "other, which includes combos of the candidates and none"
label values d1vote d1vote

gen d1disagree=.
label var d1disagree "r and D1 voted for different candidates"
replace d1disagree=1 if d1==1
replace d1disagree=0 if d1==1 & votechoice==1 & d1vote==1
replace d1disagree=0 if d1==1 & votechoice==2 & d1vote==2
replace d1disagree=0 if d1==1 & votechoice==3 & d1vote==3
replace d1disagree=0 if d1==1 & votechoice==4 & d1vote==4

/*note: the version below puts in an additional category for when the main respondent is independent
(I don't see how you can call the discussant independent, so...")*/

gen d1disagree2=.
label var d1disagree2 "r and D1 disagree on candidates - 3 point"
replace d1disagree2=2 if d1==1
replace d1disagree2=0 if d1==1 & votechoice==1 & d1vote==1
replace d1disagree2=0 if d1==1 & votechoice==2 & d1vote==2
replace d1disagree2=0 if d1==1 & votechoice==3 & d1vote==3
replace d1disagree2=0 if d1==1 & votechoice==4 & d1vote==4
replace d1disagree2=1 if pid7==4 & d1==1 & votechoice==1 & d1vote==1
replace d1disagree2=1 if pid7==4 & d1==1 & votechoice==2 & d1vote==2
replace d1disagree2=1 if pid7==4 & d1==1 & votechoice==3 & d1vote==3
replace d1disagree2=1 if pid7==4 & d1==1 & votechoice==4 & d1vote==4

/****NOTE: If R notes that Discusant voted for some other candidate, 
/*this is disagreement, because I cannot match them */


*discussant 2*/
rename v213 d2education
recode d2education 1=1 3=2 5=3 8=. 9=. 
label var d2education "level of education of 2nd discussant"
label def d2education 1 "less than high school" 2 "high school" 3 "college degree"
label values d2education d2education

rename v214 d2ptalk
label var d2ptalk "freq R talks politics with d2"
recode d2ptalk 4=0 3=1 2=2 1=3 8=. 9=. 
label def d2ptalk 0 "never" 3 "often"
label values d2ptalk d2ptalk

rename v215 d2frqdis
label var d2frqdis "freq R disagrees with d2"
recode d2frqdis 4=0 3=1 2=2 1=3 8=. 9=. 
label def d2frqdis 0 "never" 3 "often" 
label values d2frqdis d2frqdis

rename v216 d2gender 
recode d2gender 1=1 5=0 8=. 9=. 
label def d2gender 1 "male" 
label values d2gender d2gender

rename v217 d2know
label var d2know "how much d2 knows about politics"
recode d2know 5=0 3=1 1=2 8=. 9=. 
label def d2know 0 "not much" 1 "avg amount" 2 "a great deal" 
label values d2know d2know

rename v218 d2vote
label var d2vote "who did d2 vote for in election?"
recode d2vote 5=4 6=4 7=4 0=4 8=. 9=. 
label def d2vote 1 "Bush" 2 "Clinton" 3 "Perot" 4 "other, which includes combos of the candidates and none"
label values d2vote d2vote

gen d2disagree=.
label var d2disagree "r and D2 voted for different candidates"
replace d2disagree=1 if d2==1
replace d2disagree=0 if d2==1 & votechoice==1 & d2vote==1
replace d2disagree=0 if d2==1 & votechoice==2 & d2vote==2
replace d2disagree=0 if d2==1 & votechoice==3 & d2vote==3
replace d2disagree=0 if d2==1 & votechoice==4 & d2vote==4

gen d2disagree2=.
label var d2disagree2 "r and D2 disagree on candidates - 3 point"
replace d2disagree2=2 if d2==1
replace d2disagree2=0 if d2==1 & votechoice==1 & d2vote==1
replace d2disagree2=0 if d2==1 & votechoice==2 & d2vote==2
replace d2disagree2=0 if d2==1 & votechoice==3 & d2vote==3
replace d2disagree2=0 if d2==1 & votechoice==4 & d2vote==4
replace d2disagree2=1 if pid7==4 & d2==1 & votechoice==1 & d2vote==1
replace d2disagree2=1 if pid7==4 & d2==1 & votechoice==2 & d2vote==2
replace d2disagree2=1 if pid7==4 & d2==1 & votechoice==3 & d2vote==3
replace d2disagree2=1 if pid7==4 & d2==1 & votechoice==4 & d2vote==4

*/discussant 3****
******************

rename v225 d3education
recode d3education 1=1 3=2 5=3 8=. 9=. 
label var d3education "level of education of 3rd discussant"
label def d3education 1 "less than high school" 2 "high school" 3 "college degree"
label values d3education d3education 

rename v226 d3ptalk
label var d3ptalk "freq R talks politics with d3"
recode d3ptalk 4=0 3=1 2=2 1=3 8=. 9=. 
label def d3ptalk 0 "never" 3 "often"
label values d3ptalk d3ptalk 

rename v227 d3frqdis
label var d3frqdis "freq R disagrees with d3"
recode d3frqdis 4=0 3=1 2=2 1=3 8=. 9=. 
label def d3frqdis 0 "never" 3 "often" 
label values d3frqdis d3frqdis

rename v228 d3gender 
recode d3gender 1=1 5=0 8=. 9=. 
label def d3gender 1 "male" 
label values d3gender d3gender

rename v229 d3know
label var d3know "how much d3 knows about politics"
recode d3know 5=0 3=1 1=2 8=. 9=. 
label def d3know 0 "not much" 1 "avg amount" 2 "a great deal" 
label values d3know d3know

rename v230 d3vote
label var d3vote "who did d3 vote for in election?"
recode d3vote 5=4 6=4 7=4 0=4 8=. 9=. 
label def d3vote 1 "Bush" 2 "Clinton" 3 "Perot" 4 "other, which includes combos of the candidates and none"
label values d3vote d3vote

gen d3disagree=.
label var d3disagree "r and D3 voted for different candidates"
replace d3disagree=1 if d3==1
replace d3disagree=0 if d3==1 & votechoice==1 & d3vote==1
replace d3disagree=0 if d3==1 & votechoice==2 & d3vote==2
replace d3disagree=0 if d3==1 & votechoice==3 & d3vote==3
replace d3disagree=0 if d3==1 & votechoice==4 & d3vote==4

gen d3disagree2=.
label var d3disagree2 "r and D3 disagree on candidates - 3 point"
replace d3disagree2=2 if d3==1
replace d3disagree2=0 if d3==1 & votechoice==1 & d3vote==1
replace d3disagree2=0 if d3==1 & votechoice==2 & d3vote==2
replace d3disagree2=0 if d3==1 & votechoice==3 & d3vote==3
replace d3disagree2=0 if d3==1 & votechoice==4 & d3vote==4
replace d3disagree2=1 if pid7==4 & d3==1 & votechoice==1 & d3vote==1
replace d3disagree2=1 if pid7==4 & d3==1 & votechoice==2 & d3vote==2
replace d3disagree2=1 if pid7==4 & d3==1 & votechoice==3 & d3vote==3
replace d3disagree2=1 if pid7==4 & d3==1 & votechoice==4 & d3vote==4

/*discussant 4**/

rename v237 d4education
recode d4education 1=1 3=2 5=3 8=. 9=. 
label var d4education "level of education of 4th discussant"
label def d4education 1 "less than high school" 2 "high school" 3 "college degree"
label values d4education d4education 

rename v238 d4ptalk
label var d4ptalk "freq R talks politics with d4"
recode d4ptalk 4=0 3=1 2=2 1=3 8=. 9=. 
label def d4ptalk 0 "never" 3 "often"
label values d4ptalk d4ptalk

rename v239 d4frqdis
label var d4frqdis "freq R disagrees with d4"
recode d4frqdis 4=0 3=1 2=2 1=3 8=. 9=. 
label def d4frqdis 0 "never" 3 "often" 
label values d4frqdis d4frqdis

rename v240 d4gender 
recode d4gender 1=1 5=0 8=. 9=. 
label def d4gender 1 "male" 
label values d4gender

rename v241 d4know
label var d4know "how much d4 knows about politics"
recode d4know 5=0 3=1 1=2 8=. 9=. 
label def d4know 0 "not much" 1 "avg amount" 2 "a great deal" 
label values d4know d4know

rename v242 d4vote
label var d4vote "who did d4 vote for in election?"
recode d4vote 5=4 6=4 7=4 0=4 8=. 9=. 
label def d4vote 1 "Bush" 2 "Clinton" 3 "Perot" 4 "other, which includes combos of the candidates and none"
label values d4vote d4vote

gen d4disagree=.
label var d4disagree "r and D4 voted for different candidates"
replace d4disagree=1 if d4==1
replace d4disagree=0 if d4==1 & votechoice==1 & d4vote==1
replace d4disagree=0 if d4==1 & votechoice==2 & d4vote==2
replace d4disagree=0 if d4==1 & votechoice==3 & d4vote==3
replace d4disagree=0 if d4==1 & votechoice==4 & d4vote==4

gen d4disagree2=.
label var d4disagree2 "r and D4 disagree on candidates - 3 point"
replace d4disagree2=2 if d4==1
replace d4disagree2=0 if d4==1 & votechoice==1 & d4vote==1
replace d4disagree2=0 if d4==1 & votechoice==2 & d4vote==2
replace d4disagree2=0 if d4==1 & votechoice==3 & d4vote==3
replace d4disagree2=0 if d4==1 & votechoice==4 & d4vote==4
replace d4disagree2=1 if pid7==4 & d4==1 & votechoice==1 & d4vote==1
replace d4disagree2=1 if pid7==4 & d4==1 & votechoice==2 & d4vote==2
replace d4disagree2=1 if pid7==4 & d4==1 & votechoice==3 & d4vote==3
replace d4disagree2=1 if pid7==4 & d4==1 & votechoice==4 & d4vote==4

/*discussant 5**/
/*note: this is the explicitly "political" discussant*/

rename v249 d5education
recode d5education 1=1 3=2 5=3 8=. 9=. 
label var d5education "level of education of 5th discussant"
label def d5education 1 "less than high school" 2 "high school" 3 "college degree"
label values d5education d5education 

rename v250 d5ptalk
label var d5ptalk "freq R talks politics with d5"
recode d5ptalk 4=0 3=1 2=2 1=3 8=. 9=. 
label def d5ptalk 0 "never" 3 "often"
label values d5ptalk d5ptalk

rename v251 d5frqdis
label var d5frqdis "freq R disagrees with d5"
recode d5frqdis 4=0 3=1 2=2 1=3 8=. 9=. 
label def d5frqdis 0 "never" 3 "often" 
label values d5frqdis d4frqdis

rename v252 d5gender 
recode d5gender 1=1 5=0 8=. 9=. 
label def d5gender 1 "male" 
label values d5gender

rename v253 d5know
label var d5know "how much d5 knows about politics"
recode d5know 5=0 3=1 1=2 8=. 9=. 
label def d5know 0 "not much" 1 "avg amount" 2 "a great deal" 
label values d5know d5know

rename v254 d5vote
label var d5vote "who did d5 vote for in election?"
recode d5vote 5=4 6=4 7=4 0=4 8=. 9=. 
label def d5vote 1 "Bush" 2 "Clinton" 3 "Perot" 4 "other, which includes combos of the candidates and none"
label values d5vote d5vote

gen d5disagree=.
label var d5disagree "r and D5 voted for different candidates"
replace d5disagree=1 if d5==1
replace d5disagree=0 if d5==1 & votechoice==1 & d5vote==1
replace d5disagree=0 if d5==1 & votechoice==2 & d5vote==2
replace d5disagree=0 if d5==1 & votechoice==3 & d5vote==3
replace d5disagree=0 if d5==1 & votechoice==4 & d5vote==4

gen d5disagree2=.
label var d5disagree2 "r and D5 disagree on candidates - 3 point"
replace d5disagree2=2 if d5==1
replace d5disagree2=0 if d5==1 & votechoice==1 & d5vote==1
replace d5disagree2=0 if d5==1 & votechoice==2 & d5vote==2
replace d5disagree2=0 if d5==1 & votechoice==3 & d5vote==3
replace d5disagree2=0 if d5==1 & votechoice==4 & d5vote==4
replace d5disagree2=1 if pid7==4 & d5==1 & votechoice==1 & d5vote==1
replace d5disagree2=1 if pid7==4 & d5==1 & votechoice==2 & d5vote==2
replace d5disagree2=1 if pid7==4 & d5==1 & votechoice==3 & d5vote==3
replace d5disagree2=1 if pid7==4 & d5==1 & votechoice==4 & d5vote==4


gen netsize=0
replace netsize=. if d1==.
replace netsize=1 if d1==1
replace netsize=2 if d1==1 & d2==1 | d1==1 & d5==1
replace netsize=3 if d1==1 & d2==1 & d3==1 | d1==1 & d2==1 & d5==1
replace netsize=4 if d1==1 & d2==1 & d3==1 & d4==1 | d1==1 & d2==1 & d3==1 & d5==1
replace netsize=5 if d1==1 & d2==1 & d3==1 & d4==1 & d5==1
label var netsize "Size of R's network"
label values netsize netsize

gen anetknow=.
label var anetknow "Average level of political knowledge in R's network"
replace anetknow=0 if netsize==0
replace anetknow=d1know if netsize==1
replace anetknow=(d1know+d2know)/2 if netsize==2 
replace anetknow=(d1know+d5know)/2 if netsize==2 & d2==0 
replace anetknow=(d1know+d2know+d3know)/3 if netsize==3 
replace anetknow=(d1know+d2know+d5know)/3 if netsize==3 & d3==0
replace anetknow=(d1know+d2know+d3know+d4know)/4 if netsize==4 
replace anetknow=(d1know+d2know+d3know+d5know)/4 if netsize==4 & d4==0
replace anetknow=(d1know+d2know+d3know+d4know+d5know)/5 if netsize==5
label values anetknow anetknow

gen anetptalk=.
label var anetptalk "Average level of political discussion in R's network"
replace anetptalk=0 if netsize==0
replace anetptalk=d1ptalk if netsize==1
replace anetptalk=(d1ptalk+d2ptalk)/2 if netsize==2 
replace anetptalk=(d1ptalk+d5ptalk)/2 if netsize==2 & d2==0 
replace anetptalk=(d1ptalk+d2ptalk+d3ptalk)/3 if netsize==3 
replace anetptalk=(d1ptalk+d2ptalk+d5ptalk)/3 if netsize==3 & d3==0
replace anetptalk=(d1ptalk+d2ptalk+d3ptalk+d4ptalk)/4 if netsize==4 
replace anetptalk=(d1ptalk+d2ptalk+d3ptalk+d5ptalk)/4 if netsize==4 & d4==0
replace anetptalk=(d1ptalk+d2ptalk+d3ptalk+d4ptalk+d5ptalk)/5 if netsize==5
label values anetptalk anetptalk

gen afrqdis=.
label var afrqdis "Average level of political disagreement in R's network"
replace afrqdis=0 if netsize==0
replace afrqdis=d1frqdis if netsize==1
replace afrqdis=(d1frqdis+d2frqdis)/2 if netsize==2
replace afrqdis=(d1frqdis+d5frqdis)/2 if netsize==2 & d2==0
replace afrqdis=(d1frqdis+d2frqdis+d3frqdis)/3 if netsize==3
replace afrqdis=(d1frqdis+d2frqdis+d5frqdis)/3 if netsize==3 & d3==0
replace afrqdis=(d1frqdis+d2frqdis+d3frqdis+d4frqdis)/4 if netsize==4
replace afrqdis=(d1frqdis+d2frqdis+d3frqdis+d5frqdis)/4 if netsize==4 & d4==0
replace afrqdis=(d1frqdis+d2frqdis+d3frqdis+d4frqdis+d5frqdis)/5 if netsize==5
label values afrqdis afrqdis

/*this is one version of disagreement */
gen acandisag=. 
label var acandisag "average level of candidate disagreement in Rs network"
replace acandisag=0 if netsize==0
replace acandisag=d1disagree if netsize==1
replace acandisag=(d1disagree+d2disagree)/2 if netsize==2
replace acandisag=(d1disagree+d5disagree)/2 if netsize==2 & d2==0
replace acandisag=(d1disagree+d2disagree+d3disagree)/3 if netsize==3
replace acandisag=(d1disagree+d2disagree+d5disagree)/3 if netsize==3 & d3==0
replace acandisag=(d1disagree+d2disagree+d3disagree+d4disagree)/4 if netsize==4
replace acandisag=(d1disagree+d2disagree+d3disagree+d5disagree)/4 if netsize==4 & d4==0
replace acandisag=(d1disagree+d2disagree+d3disagree+d4disagree+d5disagree)/5 if netsize==5
label values acandisag acandisag

/*this is the second version (3-pt) */
gen acandisag2=. 
label var acandisag2 "average level of candidate disagreement in Rs network - 3pt"
replace acandisag2=0 if netsize==0
replace acandisag2=d1disagree2 if netsize==1
replace acandisag2=(d1disagree2+d2disagree2)/2 if netsize==2
replace acandisag2=(d1disagree2+d5disagree2)/2 if netsize==2 & d2==0
replace acandisag2=(d1disagree2+d2disagree2+d3disagree2)/3 if netsize==3
replace acandisag2=(d1disagree2+d2disagree2+d5disagree2)/3 if netsize==3 & d3==0
replace acandisag2=(d1disagree2+d2disagree2+d3disagree2+d4disagree2)/4 if netsize==4
replace acandisag2=(d1disagree2+d2disagree2+d3disagree2+d5disagree2)/4 if netsize==4 & d4==0
replace acandisag2=(d1disagree2+d2disagree2+d3disagree2+d4disagree2+d5disagree2)/5 if netsize==5
label values acandisag2 acandisag2

/*Summary Statistics*/
*This makes Table A.1 in the SI
sum partindex gender acandisag2 anetptalk netsize interest education strrep strdem age income white  



/*models */
*the following blocks of syntax 1) attempt to replicate the participation index result in Table 1 of Mutz (2002) 
*note: this is column 3 in that table; note too that she uses ordered logit and 2) then model networks effects by gender 

**************************
*reproducing Mutz result *
**************************

*model 1a: 
poisson partindex acandisag2 anetptalk netsize interest education strrep strdem age income white gender 

*comments: this produces a model that has 119 more observations than the specification she reports in the paper 

*model 1a-1: remove netsize 0s
poisson partindex acandisag2 anetptalk netsize interest education strrep strdem age income white gender if netsize>0

*comments: this produces a model that has 96 observations less than the specification she reports in the paper. 
*(However, the coefficient sizes are a better match)

*model 1b: model as over-dispersed 
nbreg partindex acandisag2 anetptalk netsize interest education strrep strdem age income white gender 

*model 1b-1: model as over-dispersed without netsize 0s
nbreg partindex acandisag2 anetptalk netsize interest education strrep strdem age income white gender if netsize>0

*note: if you remove netsize 0s, then tests suggest modeling as a poisson is suitable  

*********************************************
*adding gender interactions to specification*
*********************************************

*model 1a-1: remove netsize 0s, with gender interactions

poisson partindex c.acandisag2##i.gender c.anetptalk##i.gender c.netsize##i.gender interest education strrep strdem age income white if netsize>0

*********************************
*this makes panel A of figure 1 *
*********************************

poisson partindex acandisag2 anetptalk netsize interest education strrep strdem age income white if netsize>0 & gender==0
margins, dydx(acandisag2 anetptalk netsize) l(90)
estimates store Male 

poisson partindex acandisag2 anetptalk netsize interest education strrep strdem age income white if netsize>0 & gender==1
margins, dydx(acandisag2 anetptalk netsize) l(90)
estimates store Female 

la var netsize "Network Size"
la var anetptalk "Freq. of Discussion"
la var acandisag2 "Cross-Cutting Discussion"
coefplot Male, bylabel("Male Respondents") || Female, bylabel("Female Respondents") ///
		||,  xline(0, lc(gs10)) drop(_cons interest education strrep strdem age income white)  ///
		byop(graphregion(color(white))) mc(black) ciop(lp(dash) lc(black)) 
		text(-4 -.3 "Note: Estimates from Table 2. Dots are marginal effects and dashes are 90% CIs.")

*********************************
*this makes panel B of figure 1 *
*********************************

poisson partindex c.acandisag2##i.gender c.anetptalk##i.gender c.netsize##i.gender interest education strrep strdem age income white if netsize>0
margins, dydx(gender) at(acandisag2=(0(.1)2)) atmeans level(90)
marginsplot, level(90) yline(0, lc(black)) ytitle("Marginal Effect of Gender (Female) on Participation") graphregion(color(white)) ///
	xtitle("Cross-Cutting Discussion in Network") recastci(rspike) ciopt(lp(dash) lc(gs10)) plotop(mc(black) lc(black)) title("")






